package com.cityeye.util;

import javax.servlet.http.HttpServletRequest;

public class PageHelper {
 
 public static Page getPager(HttpServletRequest request,int totalRows,int pageRows) {
      Page pager = new Page(totalRows,pageRows);
      String currentPage = request.getParameter("curPage");
      if (currentPage != null) {
			pager.setCurPage(Integer.parseInt(currentPage));
      }

      String pagerMethod = request.getParameter("pageMethod");
      if (pagerMethod != null) {
        if (pagerMethod.equals("first")) {
			pager.first();
        } else if (pagerMethod.equals("previous")) {
			pager.previous();
        } else if (pagerMethod.equals("next")) {
			pager.next();
        } else if (pagerMethod.equals("last")) {
			pager.last();
        } else if (pagerMethod.equals("goto")) {
			String pageNumStr = request.getParameter("pageNum");		
			pager.setCurPage(Integer.parseInt(pageNumStr));;
        }
      }
      return pager;
    }
}
